/*
 * Class ActionButtons
 *
 * Version 1.0
 *
 * Monday, August 18, 2008
 *
 * Created by Palidino76 Edited by hydroPK
 */
package net.com.hydroPK.net.packethandler;

import net.com.hydroPK.Engine;
import net.com.hydroPK.Server;
import net.com.hydroPK.model.Player;
import net.com.hydroPK.model.combat.PlayerMagic;
import net.com.hydroPK.model.quest.QuestDevelopment;
import net.com.hydroPK.util.Misc;
import net.com.hydroPK.npcs.NPC;
import net.com.hydroPK.model.skills.crafting.*;

public class ActionButtons implements Packet {

    Player p;
    /**
     * Handles buttons on interfaces.
     *
     * @param p The Player which the frame should be handled for.
     * @param packetId The packet id this belongs to.
     * @param packetSize The amount of bytes being recieved for this packet.
     */
    public int color = 1; //Used for clothes stuff

    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
        QuestDevelopment quest = new QuestDevelopment(p);
        int interfaceId = p.stream.readUnsignedWord();
        int buttonId = p.stream.readUnsignedWord();
        int buttonId2 = 0;
        if (packetId == 233 || packetId == 21 || packetId == 169 || packetId == 232 || packetId == 173 || packetId == 214) {
            buttonId2 = p.stream.readUnsignedWord();
        }
        if (buttonId2 == 65535) {
            buttonId2 = 0;
        }
        //System.out.println("interfaceid:"+interfaceId+", buttonId:"+buttonId+", buttonId2:"+buttonId2);
        switch (interfaceId) {
            case 275:
                break;
                      case 154: //Normal leather crafting
                new LeatherCrafting(p, buttonId, packetId);
                break;
            case 131: //Runecrafting
                p.getActionSender().sendMessage(p, "Buy rune ess from aubury, then right click and click teleport once you buy the rune ess to runecraft");
                p.setCoords(2612, 3091, 0);
                break;
                		case 320: // Skills Tab.

				switch(buttonId) {
            case 132: //Construction
                break;
            case 134: //Agility
                break;
            case 135: //Herblore
                p.setCoords(2924, 3483, 0);
                break;
            case 136: //Thieving
                p.setCoords(2663, 3307, 0);
                break;
            case 137: //Crafting
                //p.setCoords(2933, 3285, 0);
                break;
            case 138: //Fletching
                p.setCoords(2703, 3423, 0);
                break;
            case 139: //Slayer
                break;
            case 140: //Hunter
                break;
            case 141: //Mining
                p.setCoords(3046, 9764, 0);
                break;
            case 142: //Smithing
                p.setCoords(3186, 3425, 0);
                break;
            case 143: //Fishing
                p.setCoords(2603, 3415, 0);
                break;
            case 144: //Cooking
                p.setCoords(3146, 3452, 0);
                break;
            case 145: //Firemaking
                p.setCoords(2713, 3433, 0);
                break;
            case 146: //Woodcutting
                p.setCoords(2702, 3424, 0);
                break;
            case 147: //Farming
                break;
                                }
                                break;

            case 589:
                if (buttonId == 9) {
                    p.getActionSender().showInterface(p, 590);
                }
                break;
            case 300:
                if (buttonId == 25) {
                    p.smithing.smith(p, p.smithing.type, 1, 25);
                }
                if (buttonId == 24) {
                    p.smithing.smith(p, p.smithing.type, 5, 24);
                }
// make if (buttonId == 23) {
// x p.smithing.smith(p,p.smithing.type,1,23);
// }
                if (buttonId == 22) {
                    p.smithing.smith(p, p.smithing.type, 28, 22);
                }
                if (buttonId == 33) {
                    p.smithing.smith(p, p.smithing.type, 1, 33);
                }
                if (buttonId == 32) {
                    p.smithing.smith(p, p.smithing.type, 5, 32);
                }
// make if (buttonId == 31) {
// x p.smithing.smith(p,p.smithing.type,1,31);
// }
                if (buttonId == 30) {
                    p.smithing.smith(p, p.smithing.type, 28, 30);
                }
                if (buttonId == 41) {
                    p.smithing.smith(p, p.smithing.type, 1, 41);
                }
                if (buttonId == 40) {
                    p.smithing.smith(p, p.smithing.type, 5, 40);
                }
// make if (buttonId == 39) {
// x p.smithing.smith(p,p.smithing.type,1,39);
// }
                if (buttonId == 38) {
                    p.smithing.smith(p, p.smithing.type, 28, 38);
                }
                if (buttonId == 49) {
                    p.smithing.smith(p, p.smithing.type, 1, 49);
                }
                if (buttonId == 48) {
                    p.smithing.smith(p, p.smithing.type, 5, 48);
                }
// make if (buttonId == 47) {
// x p.smithing.smith(p,p.smithing.type,1,47);
// }
                if (buttonId == 46) {
                    p.smithing.smith(p, p.smithing.type, 28, 46);
                }
                if (buttonId == 54) {
                    p.smithing.smith(p, p.smithing.type, 1, 54);
                }
                if (buttonId == 55) {
                    p.smithing.smith(p, p.smithing.type, 5, 55);
                }
// make if (buttonId == 56) {
// x p.smithing.smith(p,p.smithing.type,1,56);
// }
                if (buttonId == 57) {
                    p.smithing.smith(p, p.smithing.type, 28, 57);
                }
                if (buttonId == 62) {
                    p.smithing.smith(p, p.smithing.type, 1, 62);
                }
                if (buttonId == 63) {
                    p.smithing.smith(p, p.smithing.type, 5, 63);
                }
// make if (buttonId == 64) {
// x p.smithing.smith(p,p.smithing.type,1,64);
// }
                if (buttonId == 65) {
                    p.smithing.smith(p, p.smithing.type, 28, 65);
                }
                if (buttonId == 78) {
                    p.smithing.smith(p, p.smithing.type, 1, 78);
                }
                if (buttonId == 79) {
                    p.smithing.smith(p, p.smithing.type, 5, 79);
                }
// make if (buttonId == 80) {
// x p.smithing.smith(p,p.smithing.type,1,80);
// }
                if (buttonId == 81) {
                    p.smithing.smith(p, p.smithing.type, 28, 81);
                }
                if (buttonId == 113) {
                    p.smithing.smith(p, p.smithing.type, 1, 113);
                }
                if (buttonId == 112) {
                    p.smithing.smith(p, p.smithing.type, 5, 112);
                }
// make if (buttonId == 111) {
// x p.smithing.smith(p,p.smithing.type,1,111);
// }
                if (buttonId == 110) {
                    p.smithing.smith(p, p.smithing.type, 28, 110);
                }
                if (buttonId == 121) {
                    p.smithing.smith(p, p.smithing.type, 1, 121);
                }
                if (buttonId == 120) {
                    p.smithing.smith(p, p.smithing.type, 5, 120);
                }
// make if (buttonId == 119) {
// x p.smithing.smith(p,p.smithing.type,1,119);
// }
                if (buttonId == 118) {
                    p.smithing.smith(p, p.smithing.type, 28, 118);
                }
                if (buttonId == 129) {
                    p.smithing.smith(p, p.smithing.type, 1, 129);
                }
                if (buttonId == 128) {
                    p.smithing.smith(p, p.smithing.type, 5, 128);
                }
// make if (buttonId == 127) {
// x p.smithing.smith(p,p.smithing.type,1,127);
// }
                if (buttonId == 126) {
                    p.smithing.smith(p, p.smithing.type, 28, 126);
                }
                if (buttonId == 137) {
                    p.smithing.smith(p, p.smithing.type, 1, 137);
                }
                if (buttonId == 136) {
                    p.smithing.smith(p, p.smithing.type, 5, 136);
                }
// make if (buttonId == 135) {
// x p.smithing.smith(p,p.smithing.type,1,135);
// }
                if (buttonId == 134) {
                    p.smithing.smith(p, p.smithing.type, 28, 134);
                }
                if (buttonId == 145) {
                    p.smithing.smith(p, p.smithing.type, 1, 145);
                }
                if (buttonId == 144) {
                    p.smithing.smith(p, p.smithing.type, 5, 144);
                }
// make if (buttonId == 143) {
// x p.smithing.smith(p,p.smithing.type,1,143);
// }
                if (buttonId == 142) {
                    p.smithing.smith(p, p.smithing.type, 28, 142);
                }
                if (buttonId == 153) {
                    p.smithing.smith(p, p.smithing.type, 1, 153);
                }
                if (buttonId == 152) {
                    p.smithing.smith(p, p.smithing.type, 5, 152);
                }
// make if (buttonId == 151) {
// x p.smithing.smith(p,p.smithing.type,1,151);
// }
                if (buttonId == 150) {
                    p.smithing.smith(p, p.smithing.type, 28, 150);
                }
                if (buttonId == 161) {
                    p.smithing.smith(p, p.smithing.type, 1, 161);
                }
                if (buttonId == 160) {
                    p.smithing.smith(p, p.smithing.type, 5, 160);
                }
// make if (buttonId == 159) {
// x p.smithing.smith(p,p.smithing.type,1,159);
// }
                if (buttonId == 158) {
                    p.smithing.smith(p, p.smithing.type, 28, 158);
                }
                if (buttonId == 185) {
                    p.smithing.smith(p, p.smithing.type, 1, 185);
                }
                if (buttonId == 184) {
                    p.smithing.smith(p, p.smithing.type, 5, 184);
                }
// make if (buttonId == 183) {
// x p.smithing.smith(p,p.smithing.type,1,183);
// }
                if (buttonId == 182) {
                    p.smithing.smith(p, p.smithing.type, 28, 182);
                }
                if (buttonId == 193) {
                    p.smithing.smith(p, p.smithing.type, 1, 193);
                }
                if (buttonId == 192) {
                    p.smithing.smith(p, p.smithing.type, 5, 192);
                }
                if (buttonId == 191) {
                    p.smithing.smith(p, p.smithing.type, 1, 191);
                }
                if (buttonId == 190) {
                    p.smithing.smith(p, p.smithing.type, 28, 190);
                }
                if (buttonId == 201) {
                    p.smithing.smith(p, p.smithing.type, 1, 201);
                }
                if (buttonId == 200) {
                    p.smithing.smith(p, p.smithing.type, 5, 200);
                }
                if (buttonId == 199) {
                    p.smithing.smith(p, p.smithing.type, 1, 199);
                }
                if (buttonId == 198) {
                    p.smithing.smith(p, p.smithing.type, 28, 198);
                }
                if (buttonId == 209) {
                    p.smithing.smith(p, p.smithing.type, 1, 209);
                }
                if (buttonId == 208) {
                    p.smithing.smith(p, p.smithing.type, 5, 208);
                }
                if (buttonId == 207) {
                    p.smithing.smith(p, p.smithing.type, 1, 207);
                }
                if (buttonId == 206) {
                    p.smithing.smith(p, p.smithing.type, 28, 206);
                }
                if (buttonId == 225) {
                    p.smithing.smith(p, p.smithing.type, 1, 225);
                }
                if (buttonId == 224) {
                    p.smithing.smith(p, p.smithing.type, 5, 224);
                }
                if (buttonId == 223) {
                    p.smithing.smith(p, p.smithing.type, 1, 223);
                }
                if (buttonId == 222) {
                    p.smithing.smith(p, p.smithing.type, 28, 222);
                }
                if (buttonId == 233) {
                    p.smithing.smith(p, p.smithing.type, 1, 233);
                }
                if (buttonId == 232) {
                    p.smithing.smith(p, p.smithing.type, 5, 232);
                }
                if (buttonId == 231) {
                    p.smithing.smith(p, p.smithing.type, 1, 231);
                }
                if (buttonId == 230) {
                    p.smithing.smith(p, p.smithing.type, 28, 230);
                }
                if (buttonId == 241) {
                    p.smithing.smith(p, p.smithing.type, 1, 241);
                }
                if (buttonId == 240) {
                    p.smithing.smith(p, p.smithing.type, 5, 240);
                }
                if (buttonId == 239) {
                    p.smithing.smith(p, p.smithing.type, 1, 239);
                }
                if (buttonId == 238) {
                    p.smithing.smith(p, p.smithing.type, 28, 238);
                }
                if (buttonId == 249) {
                    p.smithing.smith(p, p.smithing.type, 1, 249);
                }
                if (buttonId == 248) {
                    p.smithing.smith(p, p.smithing.type, 5, 248);
                }
                if (buttonId == 247) {
                    p.smithing.smith(p, p.smithing.type, 1, 247);
                }
                if (buttonId == 246) {
                    p.smithing.smith(p, p.smithing.type, 28, 246);
                }
                break;
            case 620:
            case 621:
                p.shopHandler.handleoption(p, interfaceId, buttonId, buttonId2, packetId);
                break;
            //switch (interfaceId) {

            case 523:
                if (buttonId == 100) {
                    p.getActionSender().setTab(p, 79, p.spellbook);
                }
                break;
            case 663:
                NPC np = Engine.npcs[p.FamiliarID];
                switch (buttonId) {
                    case 23://Dismiss
                        if (np != null) {
                            p.FamiliarType = 0;
                            np.isDead = true;
                            p.FamiliarID = 0;
                            p.getActionSender().setTab(p, 80, 18);
                        }
                        break;

                    case 21://call
                        if (np != null) {
                            np.absX = p.absX;
                            np.absY = p.absY + 1;
                            np.heightLevel = p.heightLevel;
                            p.requestGFX(1315, 0);
                        }
                        break;
                }

                break;
            case 274:
            	if (buttonId == 3) {
            		if (p.donor == true || p.rights > 0) {
            		p.getActionSender().setTab(p, 75, 259);
            		p.getActionSender().setString(p, "<col=33FF33>Donator Command's", 259, 1);
            		p.getActionSender().setString(p, "<col=FFFFFF>Veng runes", 259, 2);
            		p.getActionSender().setString(p, "<col=FFFFFF>Barrage runes", 259, 3);
            		p.getActionSender().setString(p, "<col=FFFFFF>Overload", 259, 4);
            		p.getActionSender().setString(p, "<col=FFFFFF>AGS/Range PK Pack", 259, 5);
            		p.getActionSender().setString(p, "<col=33FF33>More commands", 259, 6);
            		p.getActionSender().setString(p, "", 259, 7);
            		p.getActionSender().setString(p, "", 259, 8);
            		p.getActionSender().setString(p, "<col=33FF33Rune Resort's Donators", 259, 9);
            		p.getActionSender().setString(p, "", 259, 10);
            		p.getActionSender().setString(p, "", 259, 11);
            		p.getActionSender().setString(p, "", 259, 12);
            		p.getActionSender().setString(p, "", 259, 13);
            		p.getActionSender().setString(p, "", 259, 14);
            		p.getActionSender().setString(p, "", 259, 15);
            		p.getActionSender().setString(p, "", 259, 16);
            		p.getActionSender().setString(p, "", 259, 17);
            		p.getActionSender().setString(p, "", 259, 18);
            		p.getActionSender().setString(p, "", 259, 19);
            		p.getActionSender().setString(p, "", 259, 20);
            		p.getActionSender().setString(p, "", 259, 21);
            		p.getActionSender().setString(p, "", 259, 22);
            		p.getActionSender().setString(p, "<col=FFFFFF>Open Bank", 259, 23);
            		p.getActionSender().setString(p, "<col=FFFFFF>Open Shop", 259, 24);
            		p.getActionSender().setString(p, "<col=FFFFFF>Recharge Prayer", 259, 25);
            		p.getActionSender().setString(p, "<col=FFFFFF>Recharge Spec", 259, 26);
            		p.getActionSender().setString(p, "", 259, 27);
            		p.getActionSender().setString(p, "", 259, 28);
            		p.getActionSender().setString(p, "", 259, 29);
            	} else if (p.donor == false || p.rights == 0) {
            		p.getActionSender().sendMessage(p, "This is Donator Only!");
            	}
            	}
//chickdick
                if (buttonId == 12) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("You Teleport Home.");
                    p.teleportTo(2330, 3688, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 13) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("You Teleport to shops.");
                    p.teleportTo(3367, 3275, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 14) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to PVP1.");
                    p.teleportTo(3186, 3444, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 15) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to PVP2.");
                    p.teleportTo(3013, 3357, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 16) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to PVP3.");
                    p.teleportTo(2946, 3369, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 17) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to FunPK, you don't lose your items here!");
                    p.teleportTo(3134, 3635, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 19) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to Corporeal Beast.");
                    p.teleportTo(2974, 4384, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 20) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to Tormented Demon.");
                    p.teleportTo(1974, 4908, 2, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 21) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to Abyssal Demons.");
                    p.teleportTo(3414, 3557, 2, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 22) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to Dark Beasts.");
                    p.teleportTo(3439, 3553, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 23) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to Kalphite Queen.");
                    p.teleportTo(3507, 9494, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 24) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to King Black Dragon.");
                    p.teleportTo(2271, 4681, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 26) {
                	if (p.wildernessZone(p.absX, p.absY)) {
                		p.message("You cannot teleport to this dungeon in the wild!");
                		return;
                	}
    				p.teleportTo(3097, 9868, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
    				p.message("You teleport to the dungeon!");
                }
                if (buttonId == 28) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to Bandos.");
                    p.teleportTo(2850, 5333, 2, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 29) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to Saradomin.");
                    p.teleportTo(2910, 5269, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 30) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to zamorak.");
                    p.teleportTo(2885, 5344, 2, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 25) {
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot teleport whilst in the wilderness.");
                        return;
                    }
                    p.message("Welcome to armadyl.");
                    p.teleportTo(2872, 5268, 2, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
                }
                if (buttonId == 5) {
                    p.getActionSender().sendMessage(p, "There are currently 		"
                            + Engine.getPlayerCount() + " players online.");
                }
                break;
            case 378:
                if (buttonId == 140) {
                    p.getActionSender().setWindowPane(p, 548);
                }
                break;
            case 105: // GE Buttons?
                break;


            case 583:
                if (buttonId == 50) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 14484, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You need 30 Pk Points to buy Dragon Claws.");
                    }
                }
                if (buttonId == 51) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13887, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You need 30 Pk Points to buy Vesta Chain.");
                    }
                }
                if (buttonId == 52) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13893, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You need 30 Points to buy Vesta Skirts.");
                    }
                }
                if (buttonId == 53) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13899, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You need 30 Points to buy Vesta Long.");
                    }
                }

                if (buttonId == 54) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13896, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You need 30 Points to buy Statius Helm.");
                    }
                }
                if (buttonId == 55) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13890, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You need 30 Points to buy Statius Legs.");
                    }
                }
                if (buttonId == 56) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13884, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You need 30 Points to buy Statius Plate Body.");
                    }
                }
                if (buttonId == 57) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13902, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 30 Pk Points To Buy a Statius Warhammer.");
                    }
                }
                if (buttonId == 58) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13858, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 30 Pk Points To Buy Zuriel's Robe Top.");
                    }
                }
                if (buttonId == 59) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13861, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 30 Pk Points to buy Zuriel's Robe Bottom.");
                    }
                }
                if (buttonId == 60) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13864, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 30 Pk Points To Buy Zuriel's Hood.");
                    }
                }
                if (buttonId == 61) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13870, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 30 Pk Points To Buy Morrigan's Leather Body.");
                    }
                }
                if (buttonId == 62) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13873, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 30 Pk Points To Buy Morrigan's Leather Chaps.");
                    }
                }
                if (buttonId == 63) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13876, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 30 Pk Points To Buy Morrigan's Coif.");
                    }
                }
                if (buttonId == 64) {
                    if (p.KC >= 30) {
                        Engine.playerItems.addItem(p, 13879, 1);
                        p.KC -= 30;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 30 Pk Points To Buy Morrigan's Javelin.");
                    }
                }
                if (buttonId == 65) {
                    if (p.KC >= 50) {
                        Engine.playerItems.addItem(p, 1038, 1);
                        p.KC -= 50;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 5 Pk Points To Buy a Red Partyhat.");
                    }
                }
                if (buttonId == 66) {
                    if (p.KC >= 50) {
                        Engine.playerItems.addItem(p, 1040, 1);
                        p.KC -= 50;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 50 Pk Points To Buy a Yellow Partyhat");
                    }
                }
                if (buttonId == 67) {
                    if (p.KC >= 50) {
                        Engine.playerItems.addItem(p, 1042, 1);
                        p.KC -= 50;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 50 Pk Points To Buy a Blue PartyHat.");
                    }
                }
                if (buttonId == 68) {
                    if (p.KC >= 50) {
                        Engine.playerItems.addItem(p, 1044, 1);
                        p.KC -= 50;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 50 Pk Points To Buy a Green Partyhat.");
                    }
                }
                if (buttonId == 69) {
                    if (p.KC >= 50) {
                        Engine.playerItems.addItem(p, 1046, 1);
                        p.KC -= 50;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 50 Pk Points To Buy a Purple Partyhat.");
                    }
                }

                if (buttonId == 70) {
                    if (p.rights >= 1) {
                    if (p.KC >= 50) {
                        Engine.playerItems.addItem(p, 1048, 1);
                        p.KC -= 50;
                    } else {
                        p.getActionSender().sendMessage(p, "You need 50 pk points to buy this party hat!");
                    }
                    } else {
                        p.getActionSender().sendMessage(p, "You Need to be a staff member to get this Party Hat.");
                    }
                }
                if (buttonId == 71) {
                    if (p.KC >= 50) {
                        Engine.playerItems.addItem(p, 1050, 1);
                        p.KC -= 50;
                    } else {
                        p.getActionSender().sendMessage(p, "You Need 50 Pk Points To Buy a Santa hat.");
                    }
                }
                break;
	case 259: //acheivement tab
		if (buttonId == 8) { //to go to quest tab
	p.getActionSender().setTab(p, 75, 274);
    p.getActionSender().setString(p, "", 274, 1);
	p.getActionSender().setString(p, "", 274, 2);
	p.getActionSender().setString(p, "", 274, 3);
	p.getActionSender().setString(p, "", 274, 4);
	p.getActionSender().setString(p, "", 274, 5);
	p.getActionSender().setString(p, "", 274, 6);
	p.getActionSender().setString(p, "", 274, 7);
	p.getActionSender().setString(p, "", 274, 8);
	p.getActionSender().setString(p, "", 274, 9);
	p.getActionSender().setString(p, "", 274, 10);
	p.getActionSender().setString(p, "", 274, 11);
	p.getActionSender().setString(p, "<img=0><img=1><col=FF0080>Rune Resort<img=1><img=0>", 274, 12);
	p.getActionSender().setString(p, "<img=1><col=FF0080>Shops", 274, 13);
	p.getActionSender().setString(p, "<img=1><col=43C6DB>PvP1<col=ff0000> UnSafe!", 274, 14);
	p.getActionSender().setString(p, "<img=1><col=43C6DB>PvP2<col=ff0000> UnSafe!", 274, 15);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>PvP3<col=ff0000> UnSafe!", 274, 16);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>FunPK<col=ff0000> SAFE (:", 274, 17);
        p.getActionSender().setString(p, "", 274, 18);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>Corperal Beast", 274, 19);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>Tormented Demon", 274, 20);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>Abyss", 274, 21);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>Dark Beast", 274, 22);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>Kalphite Queen", 274, 23);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>King Black Dragon", 274, 24);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>Armadyl", 274, 25);
        p.getActionSender().setString(p, "", 274, 26);
        p.getActionSender().setString(p, "<col=56C6DB>GODWARS TELEPORTS", 274, 27);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>Bandos", 274, 28);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>Saradomin", 274, 29);
        p.getActionSender().setString(p, "<img=1><col=43C6DB>Zamorak", 274, 30);
        p.getActionSender().setString(p, "", 274, 31);
        p.getActionSender().setString(p, "", 274, 32);
        p.getActionSender().setString(p, "<col=ff0000>Username: <col=FFFFFF>"+p.username+"", 274, 33);
        p.getActionSender().setString(p, "", 274, 34);
        p.getActionSender().setString(p, "<col=ff0000>Kills: <col=FFFFFF>"+p.KC+"", 274, 35);
        p.getActionSender().setString(p, "", 274, 37);
        p.getActionSender().setString(p, "<col=ff0000>Deaths: <col=FFFFFF>"+p.DC+"", 274, 36);
        p.getActionSender().setString(p, "", 274, 38);
        p.getActionSender().setString(p, "", 274, 39);
        p.getActionSender().setString(p, "", 274, 40);
        p.getActionSender().setString(p, "", 274, 41);
        p.getActionSender().setString(p, "", 274, 42);
        p.getActionSender().setString(p, "", 274, 43);
        p.getActionSender().setString(p, "", 274, 44);
        p.getActionSender().setString(p, "", 274, 45);
        p.getActionSender().setString(p, "", 274, 46);
        p.getActionSender().setString(p, "", 274, 47);
        p.getActionSender().setString(p, "", 274, 48);
        p.getActionSender().setString(p, "", 274, 49);
        p.getActionSender().setString(p, "", 274, 50);
        p.getActionSender().setString(p, "", 274, 51);
        p.getActionSender().setString(p, "", 274, 52);
        p.getActionSender().setString(p, "", 274, 53);
        p.getActionSender().setString(p, "", 274, 34);
        p.getActionSender().setString(p, "", 274, 55);
        p.getActionSender().setString(p, "", 274, 56);
        p.getActionSender().setString(p, "", 274, 57);
        p.getActionSender().setString(p, "", 274, 58);
        p.getActionSender().setString(p, "", 274, 59);
        p.getActionSender().setString(p, "", 274, 60);
        p.getActionSender().setString(p, "", 274, 61);
        p.getActionSender().setString(p, "", 274, 62);
        p.getActionSender().setString(p, "", 274, 63);
        p.getActionSender().setString(p, "", 274, 64);
        p.getActionSender().setString(p, "", 274, 65);
        p.getActionSender().setString(p, "", 274, 66);
        p.getActionSender().setString(p, "", 274, 67);
        p.getActionSender().setString(p, "", 274, 68);
        p.getActionSender().setString(p, "", 274, 69);
        p.getActionSender().setString(p, "", 274, 70);
        p.getActionSender().setString(p, "", 274, 71);
        p.getActionSender().setString(p, "", 274, 72);
        p.getActionSender().setString(p, "", 274, 73);
        p.getActionSender().setString(p, "", 274, 74);
        p.getActionSender().setString(p, "", 274, 75);
        p.getActionSender().setString(p, "", 274, 76);
        p.getActionSender().setString(p, "", 274, 77);
        p.getActionSender().setString(p, "", 274, 78);
        p.getActionSender().setString(p, "", 274, 79);
        p.getActionSender().setString(p, "", 274, 80);
        p.getActionSender().setString(p, "", 274, 81);
        p.getActionSender().setString(p, "", 274, 82);
        p.getActionSender().setString(p, "", 274, 83);
        p.getActionSender().setString(p, "", 274, 84);
        p.getActionSender().setString(p, "", 274, 85);
        p.getActionSender().setString(p, "", 274, 86);
        p.getActionSender().setString(p, "", 274, 87);
        p.getActionSender().setString(p, "", 274, 88);
        p.getActionSender().setString(p, "", 274, 89);
        p.getActionSender().setString(p, "", 274, 90);
        p.getActionSender().setString(p, "", 274, 91);
        p.getActionSender().setString(p, "", 274, 92);
        p.getActionSender().setString(p, "", 274, 93);
        p.getActionSender().setString(p, "", 274, 94);
        p.getActionSender().setString(p, "", 274, 95);
        p.getActionSender().setString(p, "", 274, 96);
        p.getActionSender().setString(p, "", 274, 97);
        p.getActionSender().setString(p, "", 274, 98);
        p.getActionSender().setString(p, "", 274, 99);
        p.getActionSender().setString(p, "", 274, 100);
        p.getActionSender().setString(p, "", 274, 101);
        p.getActionSender().setString(p, "", 274, 102);
        p.getActionSender().setString(p, "", 274, 103);
        p.getActionSender().setString(p, "", 274, 104);
        p.getActionSender().setString(p, "", 274, 105);
        p.getActionSender().setString(p, "", 274, 106);
        p.getActionSender().setString(p, "", 274, 107);
        p.getActionSender().setString(p, "", 274, 108);
        p.getActionSender().setString(p, "", 274, 109);
        p.getActionSender().setString(p, "", 274, 110);
        p.getActionSender().setString(p, "", 274, 111);
        p.getActionSender().setString(p, "", 274, 112);
        p.getActionSender().setString(p, "", 274, 113);
        p.getActionSender().setString(p, "", 274, 114);
        p.getActionSender().setString(p, "", 274, 115);
        p.getActionSender().setString(p, "", 274, 116);
        p.getActionSender().setString(p, "", 274, 117);
        p.getActionSender().setString(p, "", 274, 118);
        p.getActionSender().setString(p, "", 274, 119);
        p.getActionSender().setString(p, "", 274, 120);
        p.getActionSender().setString(p, "", 274, 121);
        p.getActionSender().setString(p, "", 274, 122);
        p.getActionSender().setString(p, "", 274, 123);
        p.getActionSender().setString(p, "", 274, 124);
        p.getActionSender().setString(p, "", 274, 125);
        p.getActionSender().setString(p, "", 274, 126);
        p.getActionSender().setString(p, "", 274, 127);
        p.getActionSender().setString(p, "", 274, 128);
        p.getActionSender().setString(p, "", 274, 129);
        p.getActionSender().setString(p, "", 274, 130);
        p.getActionSender().setString(p, "", 274, 131);
        p.getActionSender().setString(p, "", 274, 132);
        p.getActionSender().setString(p, "", 274, 133);
        p.getActionSender().setString(p, "", 274, 134);
        p.getActionSender().setString(p, "", 274, 135);
        p.getActionSender().setString(p, "", 274, 136);
        p.getActionSender().setString(p, "", 274, 137);
        p.getActionSender().setString(p, "", 274, 138);
        p.getActionSender().setString(p, "", 274, 139);
        p.getActionSender().setString(p, "", 274, 140);
        p.getActionSender().setString(p, "", 274, 141);
        p.getActionSender().setString(p, "", 274, 142);
        p.getActionSender().setString(p, "", 274, 143);
        p.getActionSender().setString(p, "", 274, 144);
        p.getActionSender().setString(p, "", 274, 145);
        p.getActionSender().setString(p, "", 274, 146);
        p.getActionSender().setString(p, "", 274, 147);
        p.getActionSender().setString(p, "", 274, 148);
        p.getActionSender().setString(p, "", 274, 149);
        p.getActionSender().setString(p, "", 274, 150);
        p.getActionSender().setString(p, "", 274, 151);
        p.getActionSender().setString(p, "", 274, 152);
        p.getActionSender().setString(p, "", 274, 153);
        p.getActionSender().setString(p, "", 274, 154);
        p.getActionSender().setString(p, "", 274, 155);
        p.getActionSender().setString(p, "", 274, 156);
        p.getActionSender().setString(p, "", 274, 157);
        p.getActionSender().setString(p, "", 274, 158);
        p.getActionSender().setString(p, "", 274, 159);
        p.getActionSender().setString(p, "", 274, 160);
        p.getActionSender().setString(p, "", 274, 161);
        p.getActionSender().setString(p, "", 274, 162);
        p.getActionSender().setString(p, "", 274, 163);
        p.getActionSender().setString(p, "", 274, 164);
        p.getActionSender().setString(p, "", 274, 165);
        p.getActionSender().setString(p, "", 274, 163);
		}
    	if (p.donor == true || p.rights > 0) {
            if (buttonId == 2) { //VENGEANCE FOR FREE
                if (p.wildernessZone(p.absX, p.absY)) {
                    p.message("You cannot teleport whilst in the wilderness.");
                    return;
            }
                p.message("You spawn Vengeance Runes for Free!");
                Engine.playerItems.addItem(p, 9075, 1000);
                Engine.playerItems.addItem(p, 560, 1000);
                Engine.playerItems.addItem(p, 557, 1000);
            }
            if (buttonId == 3) { //BARRAGE FOR FREE
                if (p.wildernessZone(p.absX, p.absY)) {
                    p.message("You cannot teleport whilst in the wilderness.");
                    return;
            }
                p.message("You spawn Barrage Runes for Free!");
                Engine.playerItems.addItem(p, 565, 1000);
                Engine.playerItems.addItem(p, 560, 1000);
                Engine.playerItems.addItem(p, 555, 1000);
            }
            if (buttonId == 4) { //OVERLOAD FOR FREE
                    p.message("Currently unavailable. Please be patient, we are working on it :)");
            }
            if (buttonId == 5) { //AGS/Range PK Pack
                if (p.wildernessZone(p.absX, p.absY)) {
                    p.message("You cannot spawn these items in the wild!");
                    return;
                }
                if (Engine.playerItems.freeSlotCount(p) < 11) {
                    p.message("You need 11 free spaces in your inventory to use this command!");
                } else if (Engine.playerItems.hasPlayerItemAmount(p, 995, 5000000)) {
                    Engine.playerItems.deleteItem(p, 995, Engine.playerItems.getItemSlot(p, 995), 5000000);
                    Engine.playerItems.addItem(p, 10828, 1);
                    Engine.playerItems.addItem(p, 2503, 1);
                    Engine.playerItems.addItem(p, 2497, 1);
                    Engine.playerItems.addItem(p, 6585, 1);
                    Engine.playerItems.addItem(p, 6737, 1);
                    Engine.playerItems.addItem(p, 6570, 1);
                    Engine.playerItems.addItem(p, 10498, 1);
                    Engine.playerItems.addItem(p, 5627, 50000);
                    Engine.playerItems.addItem(p, 861, 1);
                    Engine.playerItems.addItem(p, 11694, 1);
                    p.message("You spawned an ags/range fight pack for 5M!");
                } else {
                    p.message("You need 5M to spawn this pack!");
                }
            }
            if (buttonId == 23) { //open bank button
                            if (p.wildernessZone(p.absX, p.absY)) {
                                    p.message("You cannot use your bank while in the wild!");
                                    return;
                            }
                            p.openBank();
                    }
            if (buttonId == 25) { //restore prayer
                    if (p.wildernessZone(p.absX, p.absY)) {
                            p.message("You cannot use restore Prayer in the wild!");
                            return;
                    }
                    p.message("You reset your prayer.");
                            p.skillLvl[5] = 99;
                            p.getActionSender().setSkillLvl(p, 5);
            }
            if (buttonId == 26) { //restore Special
                    if (p.wildernessZone(p.absX, p.absY)) {
                            p.message("You cannot use restore Special in the wild!");
                            return;
                    }
                        p.message("You reset your special.");
                p.specAmount = 1000;
                p.getActionSender().setConfig2(p, 300, 1000);
            }
            if (p.donor == true) {
                if (buttonId == 24) { //open donator shop
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.message("You cannot open this shop in the wild!");
                        return;
                    }
                    p.message("You open the Donator Shop!");
                    p.getActionSender().setTab(p, 76, 670);
                    p.getActionSender().setTab(p, 76, 149);
                    p.shopHandler.openshop(p, 20);
                }
            }
        } else {
                    p.getActionSender().sendMessage(p, "You must be Donator or Staff to view this tab.");
        }
        break;




            case 591:
                p.appearanceUpdateReq = true;
                p.updateReq = true;
                switch (buttonId) {

                    case 182:
                        color = 1;
                        break;

                    case 183:
                        color = 1;
                        break;

                    case 184:
                        color = 2;
                        break;

                    case 180:
                        p.getActionSender().removeShownInterface(p);
                        color = 1;
                        break;

//start torsos
                    case 185:
                        p.look[2] = 111;
                        break;
                    case 186:
                        p.look[2] = 116;
                        break;
                    case 187:
                        p.look[2] = 114;
                        break;
                    case 188:
                        p.look[2] = 115;
                        break;
                    case 189:
                        p.look[2] = 112;
                        break;
                    case 190:
                        p.look[2] = 113;
                        break;
                    case 191:
                        p.look[2] = 18;
                        break;
                    case 192:
                        p.look[2] = 19;
                        break;
                    case 193:
                        p.look[2] = 20;
                        break;
                    case 194:
                        p.look[2] = 21;
                        break;
                    case 195:
                        p.look[2] = 22;
                        break;
                    case 196:
                        p.look[2] = 23;
                        break;
                    case 197:
                        p.look[2] = 24;
                        break;
                    case 198:
                        p.look[2] = 25;
                        break;
//end torsos

//start sleeves
                    case 199:
                        p.look[3] = 105;
                        break;
                    case 200:
                        p.look[3] = 108;
                        break;
                    case 201:
                        p.look[3] = 107;
                        break;
                    case 202:
                        p.look[3] = 106;
                        break;
                    case 203:
                        p.look[3] = 109;
                        break;
                    case 204:
                        p.look[3] = 110;
                        break;
                    case 205:
                        p.look[3] = 28;
                        break;
                    case 206:
                        p.look[3] = 26;
                        break;
                    case 207:
                        p.look[3] = 27;
                        break;
                    case 208:
                        p.look[3] = 29;
                        break;
                    case 209:
                        p.look[3] = 30;
                        break;
                    case 210:
                        p.look[3] = 31;
                        break;
//end sleeves

//start legs
                    case 211:
                        p.look[5] = 36;
                        break;
                    case 212:
                        p.look[5] = 85;
                        break;
                    case 213:
                        p.look[5] = 37;
                        break;
                    case 214:
                        p.look[5] = 41;
                        break;
                    case 215:
                        p.look[5] = 89;
                        break;
                    case 216:
                        p.look[5] = 90;
                        break;
                    case 217:
                        p.look[5] = 39;
                        break;
                    case 218:
                        p.look[5] = 88;
                        break;
                    case 219:
                        p.look[5] = 87;
                        break;
                    case 220:
                        p.look[5] = 38;
                        break;
                    case 221:
                        p.look[5] = 86;
                        break;

                    case 280://black
                        p.color[color] = 16;
                        break;
                    case 279://dark grey
                        p.color[color] = color;
                        break;
                    case 278://taupe
                        p.color[color] = 17;
                        break;
                    case 277://light grey
                        p.color[color] = 18;
                        break;
//case 276://beige
//p.color[color] = color + 4;
//break;
                    case 275://navy blue
                        p.color[color] = color + 2;
                        break;
                    case 274://indigo
                        p.color[color] = 27;
                        break;
                    case 273://violet
                        p.color[color] = 28;
                        break;
                    case 272://mauve
                        p.color[color] = color + 9;
                        break;
                    case 270://light blue
                        p.color[color] = 20;
                        break;
                    case 271://pale blue
                        p.color[color] = color + 13;
                        break;
                    case 269://dark blue
                        p.color[color] = color + 6;
                        break;
                    case 268://royal blue
                        p.color[color] = 21;
                        break;
                    case 267://dark green
                        p.color[color] = 26;
                        break;
                    case 266://forest green
                        p.color[color] = color == 2 ? 0 : 15;
                        break;
                    case 265://sea green
                        p.color[color] = color + 7;
                        break;
                    case 264://mint green
                        p.color[color] = 25;
                        break;
                    case 263://moss green
                        p.color[color] = color + 12;
                        break;
                    case 262://gold
                        p.color[color] = color + 8;
                        break;

                    case 281:
                        color = 1;
                        break;

                    default:
                        //Misc.println("Unhandled char screen button: "  + buttonId + ":" + buttonId2);
                        break;
                }
                break;

            case 238: // Five options?
                System.out.println("Five options interface; Button: " + buttonId + ", Button2: " + buttonId2);
                break;

            case 458: // Three options
                if (p.dialogueOptionsId == 1) {
                    switch (buttonId) {
                        case 1:
                            p.teleportTo(2974, 4384, 4);
                            p.message("You teleport to the Corporal beast!");
                            p.getActionSender().removeChatboxInterface(p);
                            break;
                        case 2:
                            p.teleportTo(3507, 9494, 4);
                            p.message("You teleport to the Kalphite lair...");
                            p.getActionSender().removeChatboxInterface(p);
                            break;
                        case 3:
                            p.teleportTo(2271, 4681, 4);
                            p.message("You teleport to the Kbd.");
                            p.getActionSender().removeChatboxInterface(p);
                            break;
                    }
                } else if (p.dialogueOptionsId == 2) {
                    switch (buttonId) {
                        case 1:
                            p.teleportTo(1884, 4381, 4);
                            p.message("You teleport to the Green dragons!");
                            p.getActionSender().removeChatboxInterface(p);
                            break;
                        case 2:
                            p.teleportTo(2490, 10163, 4);
                            p.message("You teleport to the Black dragons!");
                            p.getActionSender().removeChatboxInterface(p);
                            break;
                        case 3:
                            p.getActionSender().removeChatboxInterface(p);
                            break;
                    }
                }
                break;

            case 592:
                p.appearanceUpdateReq = true;
                p.updateReq = true;
                if (buttonId == 168) {//bald
                    p.look[0] = 45;
                }
                if (buttonId == 169) {//bun
                    p.look[0] = 46;
                }
                if (buttonId == 170) {//dreadlocks
                    p.look[0] = 47;
                }
                if (buttonId == 171) {//long
                    p.look[0] = 48;
                }
                if (buttonId == 172) {//short
                    p.look[0] = 49;
                }
                if (buttonId == 173) {//pigtails
                    p.look[0] = 50;
                }
                if (buttonId == 174) {//crew cut
                    p.look[0] = 51;
                }
                if (buttonId == 175) {//close cropped
                    p.look[0] = 52;
                }
                if (buttonId == 176) {//wild spikes
                    p.look[0] = 53;
                }
                if (buttonId == 177) {//spikes
                    p.look[0] = 54;
                }
                if (buttonId == 178) {
                    p.look[0] = 135;
                }
                if (buttonId == 179) {
                    p.look[0] = 136;
                }
                if (buttonId == 180) {
                    p.look[0] = 137;
                }
                if (buttonId == 181) {
                    p.look[0] = 138;
                }
                if (buttonId == 182) {
                    p.look[0] = 139;
                }
                if (buttonId == 183) {
                    p.look[0] = 140;
                }
                if (buttonId == 184) {
                    p.look[0] = 141;
                }
                if (buttonId == 185) {
                    p.look[0] = 142;
                }
                if (buttonId == 186) {
                    p.look[0] = 143;
                }
                if (buttonId == 187) {
                    p.look[0] = 144;
                }
                break;


            case 596:
                if (buttonId == 245) {
                    p.color[0] = 1;
                }
                if (buttonId == 228) {
                    p.color[0] = 4;
                }
                if (buttonId == 229) {
                    p.color[0] = 5;
                }
                if (buttonId == 233) {
                    p.color[0] = 6;
                }
                if (buttonId == 231) {
                    p.color[0] = 7;
                }
                if (buttonId == 235) {
                    p.color[0] = 9;
                }
                if (buttonId == 226) {
                    p.color[0] = 10;
                }
                if (buttonId == 240) {
                    p.color[0] = 11;
                }
                if (buttonId == 243) {
                    p.color[0] = 3;
                }
                if (buttonId == 247) {
                    p.color[0] = 13;
                }
                if (buttonId == 230) {
                    p.color[0] = 15;
                }
                if (buttonId == 239) {
                    p.color[0] = 16;
                }
                if (buttonId == 227) {
                    p.color[0] = 18;
                }
                if (buttonId == 225) {
                    p.color[0] = 19;
                }
                if (buttonId == 224) {
                    p.color[0] = 20;
                }
                if (buttonId == 234) {
                    p.color[0] = 21;
                }
                if (buttonId == 236) {
                    p.color[0] = 22;
                }
                if (buttonId == 242) {
                    p.color[0] = 23;
                }
                if (buttonId == 241) {
                    p.color[0] = 24;
                }
                if (buttonId == 232) {
                    p.color[0] = 25;
                }
                if (buttonId == 237) {
                    p.color[0] = 17;
                }
                if (buttonId == 246) {
                    p.color[0] = 14;
                }
                if (buttonId == 244) {
                    p.color[0] = 2;
                }
                if (buttonId == 248) {
                    p.color[0] = 12;
                }
                if (buttonId == 238) {
                    p.color[0] = 8;
                }
                if (buttonId == 160) {
                    p.getActionSender().removeShownInterface(p);
                }
                if (buttonId == 167) {//bald
                    p.look[0] = 0;
                }
                if (buttonId == 168) {//dreadlocks
                    p.look[0] = 1;
                }
                if (buttonId == 169) {//long hair
                    p.look[0] = 2;
                }
                if (buttonId == 170) {//long hair
                    p.look[0] = 3;
                }
                if (buttonId == 171) {//crew cut
                    p.look[0] = 4;
                }
                if (buttonId == 172) {//crew cut
                    p.look[0] = 5;
                }
                if (buttonId == 173) {//crew cut
                    p.look[0] = 6;
                }
                if (buttonId == 174) {//Wild spikes
                    p.look[0] = 7;
                }
                if (buttonId == 175) {//Spikes
                    p.look[0] = 8;
                }
                if (buttonId == 176) {//Mohawk
                    p.look[0] = 91;
                }
                if (buttonId == 177) {
                    p.look[0] = 92;
                }
                if (buttonId == 178) {
                    p.look[0] = 93;
                }
                if (buttonId == 179) {
                    p.look[0] = 94;
                }
                if (buttonId == 180) {
                    p.look[0] = 95;
                }
                if (buttonId == 181) {
                    p.look[0] = 96;
                }
                if (buttonId == 182) {
                    p.look[0] = 97;
                }
                if (buttonId == 183) { //Goatee
                    p.look[1] = 10;
                }
                if (buttonId == 184) { //Long Beard
                    p.look[1] = 11;
                }
                if (buttonId == 185) { //Med Beard
                    p.look[1] = 12;
                }
                if (buttonId == 186) { //Mustouche
                    p.look[1] = 13;
                }
                if (buttonId == 187) { //Clean Shaven
                    p.look[1] = 14;
                }
                if (buttonId == 188) { //Short Beard
                    p.look[1] = 15;
                }
                if (buttonId == 189) { //Short Full
                    p.look[1] = 16;
                }
                if (buttonId == 190) { //Split
                    p.look[1] = 17;
                }
                if (buttonId == 191) { //Handle Bar
                    p.look[1] = 98;
                }
                if (buttonId == 192) { //Mutton
                    p.look[1] = 99;
                }
                if (buttonId == 193) { //Full Mutton
                    p.look[1] = 100;
                }
                if (buttonId == 194) { //Full Mustouche
                    p.look[1] = 101;
                }
                if (buttonId == 195) { //Waxed
                    p.look[1] = 102;
                }
                if (buttonId == 196) { //Dali
                    p.look[1] = 103;
                }
                if (buttonId == 197) { //Visier
                    p.look[1] = 104;
                } else if (buttonId != 160 || buttonId != 167 || buttonId != 168 || buttonId != 169 || buttonId != 170 || buttonId != 171 || buttonId != 172 || buttonId != 173 || buttonId != 174 || buttonId != 175 || buttonId != 176 || buttonId != 177 || buttonId != 178 || buttonId != 179 || buttonId != 180 || buttonId != 181 || buttonId != 182) {
//Misc.println("Unhandled hair button: "  + buttonId);
                }
                p.appearanceUpdateReq = true;
                p.updateReq = true;

                break;

            case 662:
                /**
                 * Summoning IDS
                 */
                if (buttonId == 50) {
                    if (p.summonedFamiliar) {
                        Server.engine.rebuildNPCs();
                    }
                    if (p.summonedFamiliar) {
                        p.callFamiliar = true;
                    }
                }
                if (buttonId == 52) {
                    if (p.summonedFamiliar) {
                        p.familiarDissMiss = true;
                    }
                }
                break;
            case 387:
                /*
                 * Equipment tab.
                 */
                if (buttonId == 55) {
                    p.setEquipmentBonus();
                    p.getActionSender().showInterface(p, 667);
                    p.getActionSender().setInventory(p, 149);
                    p.getActionSender().setItems(p, -1327, 64209, 93, p.items, p.itemsN);
                    p.getActionSender().setItems(p, -1328, 64208, 94, p.equipment, p.equipmentN);
                }
                break;
            case 659:
                if (buttonId == 2) {
                    if (packetId == 63) {
                        p.requestAnim(1745, 0);
                    }
                    p.getActionSender().removeShownInterface(p);
                    p.requestAnim(1745, 0);
                    p.getActionSender().addStaticObject(28297, p.heightLevel, p.absX, p.absY, 0, 10);
                    p.getActionSender().addStaticObject(28297, p.heightLevel, p.absX - 1, p.absY + 2, 0, 10);
                    p.getActionSender().addStaticObject(28297, p.heightLevel, p.absX + 2, p.absY - 1, 0, 10);
                    p.requestAnim(1745, 0);
                    Engine.playerItems.addItem(p, 11951, 27);
                    p.getActionSender().sendMessage(p, "The snow globe fills your inventory with snow!");
                }
                break;

            case 271:
                int prayer = -1;
                String name = "";
                if (buttonId == 5) { //Thick Skin
                    prayer = 0;
                    name = "Thick Skin";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{5, 13, 25, 26}, prayer);
                    }
                }
                if (buttonId == 5) { //Thick Skin
                    prayer = 0;
                    name = "Thick Skin";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{5, 13, 25, 26}, prayer);
                    }
                }
                if (buttonId == 7) { //Burst of Strength
                    prayer = 1;
                    name = "Burst of Strength";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{3, 4, 6, 11, 12, 14, 20, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 9) { //Clarity of Thought
                    prayer = 2;
                    name = "Clarity of Thought";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{3, 4, 7, 11, 12, 15, 20, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 11) { //Sharp Eye
                    prayer = 3;
                    name = "Sharp Eye";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{1, 2, 4, 6, 7, 11, 12, 14, 15, 20, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 13) { //Mystic Will
                    prayer = 4;
                    name = "Mystic Will";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{1, 2, 3, 6, 7, 11, 12, 14, 15, 20, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 15) { //Rock Skin
                    prayer = 5;
                    name = "Rock Skin";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{0, 13, 25, 26}, prayer);
                    }
                }
                if (buttonId == 17) { //Superhuman Strength
                    prayer = 6;
                    name = "Superhuman Strength";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{1, 3, 4, 11, 12, 14, 20, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 19) { //Improved Reflexes
                    prayer = 7;
                    name = "Improved Reflexes";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{2, 3, 4, 11, 12, 15, 20, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 21) { //Rapid Restore
                    prayer = 8;
                    name = "Rapid Restore";
                }
                if (buttonId == 23) { //Rapid Heal
                    prayer = 9;
                    name = "Rapid Heal";
                }
                if (buttonId == 25) { //Protect Item
                    prayer = 10;
                    name = "Protect Item";
                }
                if (buttonId == 27) { //Hawk Eye
                    prayer = 11;
                    name = "Hawk Eye";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{1, 2, 3, 4, 6, 7, 12, 14, 15, 20, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 29) { //Mystic Lore
                    prayer = 12;
                    name = "Mystic Lore";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{1, 2, 3, 4, 6, 7, 11, 14, 15, 20, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 31) { //Steel Skin
                    prayer = 13;
                    name = "Steel Skin";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{0, 5, 25, 26}, prayer);
                    }
                }
                if (buttonId == 33) { //Ultimate Strength
                    prayer = 14;
                    name = "Ultimate Strength";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{1, 3, 4, 6, 11, 12, 20, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 35) { //Incredible Reflexes
                    prayer = 15;
                    name = "Incredible Reflexes";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{2, 3, 4, 7, 11, 12, 20, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 53) { //Protect from Summoning
                    prayer = 16;
                    name = "Protect from Summoning";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{22, 23, 24}, prayer);
                        if (p.usingPrayer(17)) {
                            p.headIconPrayer = 10;
                        } else if (p.usingPrayer(18)) {
                            p.headIconPrayer = 9;
                        } else if (p.usingPrayer(19)) {
                            p.headIconPrayer = 8;
                        } else {
                            p.headIconPrayer = 7;
                        }
                    } else {
                        if (p.usingPrayer(17)) {
                            p.headIconPrayer = 2;
                        } else if (p.usingPrayer(18)) {
                            p.headIconPrayer = 1;
                        } else if (p.usingPrayer(19)) {
                            p.headIconPrayer = 0;
                        } else {
                            p.headIconPrayer = -1;
                        }
                    }
                }
                if (buttonId == 37) { //Protect from Magic
                    prayer = 17;
                    name = "Protect from Magic";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{18, 19, 22, 23, 24}, prayer);
                        if (p.usingPrayer(16)) {
                            p.headIconPrayer = 10;
                        } else {
                            p.headIconPrayer = 2;
                        }
                    } else {
                        if (p.usingPrayer(16)) {
                            p.headIconPrayer = 7;
                        } else {
                            p.headIconPrayer = -1;
                        }
                    }
                }
                if (buttonId == 39) { //Protect from Missiles
                    prayer = 18;
                    name = "Protect from Missiles";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{17, 19, 22, 23, 24}, prayer);
                        if (p.usingPrayer(16)) {
                            p.headIconPrayer = 9;
                        } else {
                            p.headIconPrayer = 1;
                        }
                    } else {
                        if (p.usingPrayer(16)) {
                            p.headIconPrayer = 7;
                        } else {
                            p.headIconPrayer = -1;
                        }
                    }
                }
                if (buttonId == 41) { //Protect from Melee
                    prayer = 19;
                    name = "Protect from Melee";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{17, 18, 22, 23, 24}, prayer);
                        if (p.usingPrayer(16)) {
                            p.headIconPrayer = 8;
                        } else {
                            p.headIconPrayer = 0;
                        }
                    } else {
                        if (p.usingPrayer(16)) {
                            p.headIconPrayer = 7;
                        } else {
                            p.headIconPrayer = -1;
                        }
                    }
                }
                if (buttonId == 43) { //Eagle Eye
                    prayer = 20;
                    name = "Eagle Eye";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{1, 2, 3, 4, 6, 7, 11, 12, 14, 15, 21, 25, 26}, prayer);
                    }
                }
                if (buttonId == 45) { //Mystic Might
                    prayer = 21;
                    name = "Mystic Might";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{1, 2, 3, 4, 6, 7, 11, 12, 14, 15, 20, 25, 26}, prayer);
                    }
                }
                if (buttonId == 47) { //Retribution
                    prayer = 22;
                    name = "Retribution";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{16, 17, 18, 19, 23, 24}, prayer);
                        p.headIconPrayer = 3;
                    } else {
                        p.headIconPrayer = -1;
                    }
                }
                if (buttonId == 49) { //Redemption
                    prayer = 23;
                    name = "Redemption";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{16, 17, 18, 19, 22, 24}, prayer);
                        p.headIconPrayer = 5;
                    } else {
                        p.headIconPrayer = -1;
                    }
                }
                if (buttonId == 51) { //Smite
                    prayer = 24;
                    name = "Smite";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{16, 17, 18, 19, 22, 23}, prayer);
                        p.headIconPrayer = 4;
                    } else {
                        p.headIconPrayer = -1;
                    }
                }
                if (buttonId == 55) { //Turmoil
                    prayer = 25;
                    name = "Turmoil";
                    p.requestAnim(4947, 1);
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{0, 1, 2, 3, 4, 5, 6, 7, 11, 12, 13, 14, 15, 20, 21, 26}, prayer);
                    }
                }
                if (buttonId == 57) { //Piety
                    prayer = 26;
                    name = "Piety";
                    if (!p.usingPrayer(prayer)) {
                        p.switchPrayers(new int[]{0, 1, 2, 3, 4, 5, 6, 7, 11, 12, 13, 14, 15, 20, 21, 25}, prayer);
                    }
                }
                if (!p.canPray(prayer)) {
                    p.headIconPrayer = -1;
                    if (p.getLevelForXP(5) < p.prayers[prayer][0] && p.skillLvl[5] > 0) {
                        p.getActionSender().dialogue(p, -1, -1, "", 1, "You need a <col=000080>Prayer</col> level of " + (int) p.prayers[prayer][0] + " to use <col=000080>" + name, "", "", "");
                    }
                    break;
                }
                if (prayer == 25 && p.getLevelForXP(1) < 45) {
                    p.getActionSender().dialogue(p, -1, -1, "", 1, "You need a <col=000080>Defence</col> level of 45 to use <col=000080>" + name, "", "", "");
                    break;
                }
                if (prayer == 25 && p.getLevelForXP(5) < 95) {
                    p.getActionSender().dialogue(p, -1, -1, "", 1, "You need a <col=000080>Prayer</col> level of 95 to use <col=000080>" + name, "", "", "");
                    break;
                }
                if (prayer == 26 && p.getLevelForXP(1) < 70) {
                    p.getActionSender().dialogue(p, -1, -1, "", 1, "You need a <col=000080>Defence</col> level of 70 to use <col=000080>" + name, "", "", "");
                    break;
                }
                p.togglePrayer(prayer, p.usingPrayer(prayer) ? 0 : 1);
                if (p.usingPrayer(prayer)) {
                    p.prayerSounds(prayer);
                } else {
                    p.getActionSender().addSoundEffect(p, 2663, 1, 0, 0);
                }
                p.updateReq = true;
                p.appearanceUpdateReq = true;
                break;

            case 750:
            /*
             * Running button next to minimap.
             */
            case 261:
                /*
                 * Settings tab.
                 */
                if (buttonId == 1) {
                    if (!p.isRunning) {
                        p.isRunning = true;
                        p.getActionSender().setConfig(p, 173, 1);
                    } else {
                        p.isRunning = false;
                        p.getActionSender().setConfig(p, 173, 0);
                    }
                } else if (buttonId == 14) {
                    p.getActionSender().showInterface(p, 742);
                } else if (buttonId == 16) {
                    p.getActionSender().showInterface(p, 743);
                } else if (buttonId == 3) {
                    p.splitChat = !p.splitChat;
                    p.getActionSender().setConfig(p, 287, p.splitChat ? 1 : 0);
                    if (p.splitChat) {
                        p.stream.createFrameVarSizeWord(152);
                        p.stream.writeString("s");
                        p.stream.writeDWord(83);
                        p.stream.endFrameVarSize();
                    }
                }
                break;

            case 192:
            case 193:
            case 430:
                PlayerMagic playerMagic = new PlayerMagic(p);
                playerMagic.magic(interfaceId, buttonId);
                break;

            case 464:
                /*
                 * Emote tab.
                 */
                if (buttonId == 2) // Yes
                {
                    p.requestAnim(855, 0);
                } else if (buttonId == 3) // No
                {
                    p.requestAnim(856, 0);
                } else if (buttonId == 4) // Bow
                {
                    p.requestAnim(858, 0);
                } else if (buttonId == 5) // Angry
                {
                    p.requestAnim(1746, 0);
                } else if (buttonId == 6) // Think
                {
                    p.requestAnim(857, 0);
                } else if (buttonId == 7) // Wave
                {
                    p.requestAnim(863, 0);
                } else if (buttonId == 8) // Shrug
                {
                    p.requestAnim(2113, 0);
                } else if (buttonId == 9) // Cheer
                {
                    p.requestAnim(862, 0);
                } else if (buttonId == 10) // Beckon
                {
                    p.requestAnim(10010, 0);
                } else if (buttonId == 11) // Laugh
                {
                    p.requestAnim(1972, 0);
                } else if (buttonId == 12) // Joy jump
                {
                    p.requestAnim(734, 0);
                } else if (buttonId == 13) // Yawn
                {
                    p.requestAnim(2111, 0);
                } else if (buttonId == 14) // Dance
                {
                    p.requestAnim(866, 0);
                } else if (buttonId == 15) // Jig
                {
                    p.requestAnim(2106, 0);
                } else if (buttonId == 16) // Spin
                {
                    p.requestAnim(2107, 0);
                } else if (buttonId == 17) // Headbang
                {
                    p.requestAnim(2108, 0);
                } else if (buttonId == 18) // Cry
                {
                    p.requestAnim(6381, 0);
                } else if (buttonId == 19) { // Blow kiss
                    p.requestGFX(574, 0);
                    p.requestAnim(0x558, 0);
                } else if (buttonId == 20) // Panic
                {
                    p.requestAnim(2105, 0);
                } else if (buttonId == 21) // Raspberry
                {
                    p.requestAnim(2110, 0);
                } else if (buttonId == 22) // Clap
                {
                    p.requestAnim(10013, 0);
                } //p.requestAnim(865, 0);
                else if (buttonId == 23) // Salute
                {
                    p.requestAnim(2112, 0);
                } else if (buttonId == 24) // Goblin bow
                {
                    p.requestAnim(7277, 0);
                } else if (buttonId == 25) // Goblin salute
                {
                    p.requestAnim(8996, 0);
                } else if (buttonId == 26) // Glass box
                {
                    p.requestAnim(1131, 0);
                } else if (buttonId == 27) // Climb rope
                {
                    p.requestAnim(1130, 0);
                } else if (buttonId == 28) // Lean
                {
                    p.requestAnim(1129, 0);
                } else if (buttonId == 29) // Glass wall
                {
                    p.requestAnim(1128, 0);
                } else if (buttonId == 30) // Head slap
                {
                    p.requestAnim(4275, 0);
                } else if (buttonId == 31) // Stomp
                {
                    p.requestAnim(1745, 0);
                } else if (buttonId == 32) // Flap
                {
                    p.requestAnim(4280, 0);
                } else if (buttonId == 33) // Idea
                {
                    p.requestAnim(4276, 0);
                } else if (buttonId == 34) // Zombie walk
                {
                    p.requestAnim(3544, 0);
                } else if (buttonId == 35) // Dombie dance
                {
                    p.requestAnim(3543, 0);
                } else if (buttonId == 36) { // Zombie hand grab
                    p.requestGFX(1244, 0);
                    p.requestAnim(7272, 0);
                } else if (buttonId == 37) // Scared
                {
                    p.requestAnim(2836, 0);
                } else if (buttonId == 38) // Rabbit hop
                {
                    p.requestAnim(6111, 0);
                } else if (buttonId == 39) { // Skillcape emotes
                    if (!p.skillCapeEquipped()) {
                        return;
                    }
                    if (p.animClickDelay > 0) {
                        return;
                    }
                    if (p.equipment[1] == 9747 || p.equipment[1] == 10639 || p.equipment[1] == 9748) { //attack
                        p.requestGFX(823, 1);
                        p.requestAnim(4959, 1);
                    }
                    if (p.equipment[1] == 9753 || p.equipment[1] == 10641 || p.equipment[1] == 9754) { //Defence
                        p.requestGFX(824, 1);
                        p.requestAnim(4961, 1);
                    }
                    if (p.equipment[1] == 9750 || p.equipment[1] == 10640 || p.equipment[1] == 9751) { //Strength
                        p.requestGFX(828, 1);
                        p.requestAnim(4981, 1);
                    }
                    if (p.equipment[1] == 9768 || p.equipment[1] == 10647 || p.equipment[1] == 9769) { //Hitpoints
                        p.requestGFX(833, 1);
                        p.requestAnim(4971, 1);
                    }
                    if (p.equipment[1] == 9756 || p.equipment[1] == 10642 || p.equipment[1] == 9757) { //Range
                        p.requestGFX(832, 1);
                        p.requestAnim(4973, 1);
                    }
                    if (p.equipment[1] == 9759 || p.equipment[1] == 10643 || p.equipment[1] == 9760) { //Prayer
                        p.requestGFX(829, 1);
                        p.requestAnim(4979, 1);
                    }
                    if (p.equipment[1] == 9762 || p.equipment[1] == 10644 || p.equipment[1] == 9763) { //Magic
                        p.requestGFX(813, 1);
                        p.requestAnim(4939, 1);
                    }
                    if (p.equipment[1] == 9801 || p.equipment[1] == 10658 || p.equipment[1] == 9802) { //Cooking
                        p.requestGFX(821, 1);
                        p.requestAnim(4955, 1);
                    }
                    if (p.equipment[1] == 9807 || p.equipment[1] == 10660 || p.equipment[1] == 9808) { //Woodcutting
                        p.requestGFX(822, 1);
                        p.requestAnim(4957, 1);
                    }
                    if (p.equipment[1] == 9783 || p.equipment[1] == 10652 || p.equipment[1] == 9784) { //Fletching
                        p.requestGFX(812, 1);
                        p.requestAnim(4937, 1);
                    }
                    if (p.equipment[1] == 9798 || p.equipment[1] == 10657 || p.equipment[1] == 9799) { //Fishing
                        p.requestGFX(819, 1);
                        p.requestAnim(4951, 1);
                    }
                    if (p.equipment[1] == 9804 || p.equipment[1] == 10659 || p.equipment[1] == 9805) { //Firemaking
                        p.requestGFX(831, 1);
                        p.requestAnim(4975, 1);
                    }
                    if (p.equipment[1] == 9780 || p.equipment[1] == 10651 || p.equipment[1] == 9781) { //Crafting
                        p.requestGFX(818, 1);
                        p.requestAnim(4949, 1);
                    }
                    if (p.equipment[1] == 9795 || p.equipment[1] == 10656 || p.equipment[1] == 9796) { //Smithing
                        p.requestGFX(815, 1);
                        p.requestAnim(4943, 1);
                    }
                    if (p.equipment[1] == 9792 || p.equipment[1] == 10655 || p.equipment[1] == 9793) { //Mining
                        p.requestGFX(814, 1);
                        p.requestAnim(4941, 1);
                    }
                    if (p.equipment[1] == 9774 || p.equipment[1] == 10649 || p.equipment[1] == 9775) { //Herblore
                        p.requestGFX(835, 1);
                        p.requestAnim(4969, 1);
                    }
                    if (p.equipment[1] == 9771 || p.equipment[1] == 10648 || p.equipment[1] == 9772) { //Agility
                        p.requestGFX(830, 1);
                        p.requestAnim(4977, 1);
                    }
                    if (p.equipment[1] == 9777 || p.equipment[1] == 10650 || p.equipment[1] == 9778) { //Theiving
                        p.requestGFX(826, 1);
                        p.requestAnim(4965, 1);
                    }
                    if (p.equipment[1] == 9786 || p.equipment[1] == 10653 || p.equipment[1] == 9787) { //Slayer
                        p.requestGFX(1656, 1);
                        p.requestAnim(4967, 1);
                    }
                    if (p.equipment[1] == 9810 || p.equipment[1] == 10661 || p.equipment[1] == 9811) { //Farming
                        p.requestGFX(825, 1);
                        p.requestAnim(4963, 1);
                    }
                    if (p.equipment[1] == 9765 || p.equipment[1] == 10645 || p.equipment[1] == 9766) { //Runecrafting
                        p.requestGFX(817, 1);
                        p.requestAnim(4947, 1);
                    }
                    if (p.equipment[1] == 9789 || p.equipment[1] == 10654 || p.equipment[1] == 9790) { //Construction
                        p.requestGFX(820, 1);
                        p.requestAnim(4953, 1);
                    }
                    if (p.equipment[1] == 12524 || p.equipment[1] == 12169 || p.equipment[1] == 12170) { //Summoning
                        p.requestGFX(1515, 1);
                        p.requestAnim(8525, 1);
                    }
                    if (p.equipment[1] == 9948 || p.equipment[1] == 10646 || p.equipment[1] == 9949) { // hunter
                        p.requestGFX(907, 0);
                        p.requestAnim(5158, 0);
                    }
                    if (p.equipment[1] == 9813 || p.equipment[1] == 10662) { //Quest
                        p.requestGFX(816, 1);
                        p.requestAnim(4945, 1);
                    }
                    p.animClickDelay = 10;
                } else if (buttonId == 40) // Snowman dance
                {
                    p.requestAnim(7531, 0);
                } else if (buttonId == 41) { // Air guitar
                    p.requestAnim(2414, 0);
                    p.requestGFX(1537, 0);
                } else if (buttonId == 42) { // Safety first
                    p.requestAnim(8770, 0);
                    p.requestGFX(1553, 0);
                } else if (buttonId == 43) { // Explore
                    p.requestAnim(9990, 0);
                    p.requestGFX(1734, 0);
                } else if (buttonId == 44) { // Trick
                    p.requestAnim(10530, 0);
                    p.requestGFX(1864, 0);
                } else if (buttonId == 45) { // Freeze
                    p.requestAnim(11044, 0);
                    p.requestGFX(1973, 0);
                } else if (buttonId == 46) {  //Give Thanks
                    p.turkeydelay = 28;
                }
                break;
            case 335:
            case 334:
            case 336:
                p.pTrade.buttons.handleButton(interfaceId, packetId, buttonId, buttonId2);
                break;
            case 771:
                if (buttonId == 49) {
                    p.look[0] = 3;
                    p.look[1] = 10;
                    p.look[2] = 18;
                    p.look[3] = 26;
                    p.look[4] = 33;
                    p.look[5] = 36;
                    p.look[6] = 42;
                    p.gender = 0;
                }
                if (buttonId == 52) {
                    p.look[0] = 48; // Hair
                    p.look[1] = 1000; // Beard
                    p.look[2] = 57; // Torso
                    p.look[3] = 64; // Arms
                    p.look[4] = 68; // Bracelets
                    p.look[5] = 77; // Legs
                    p.look[6] = 80; // Shoes
                    p.gender = 1;
                }
                if (buttonId == 92 && p.gender < 1) {
                    p.look[0] = p.look[0] - 1;
                    if (p.look[0] < 0) {
                        p.look[0] = 260;
                    }
                    if (p.look[0] > 8 && p.look[0] < 91) {
                        p.look[0] = 8;
                    }
                    if (p.look[0] > 97 && p.look[0] < 246) {
                        p.look[0] = 97;
                    }
                    if (p.look[0] > 260 && p.look[0] < 1000) {
                        p.look[0] = 260;
                    }
                }
                if (buttonId == 92 && p.gender > 0) {
                    p.look[0] = p.look[0] - 1;
                    if (p.look[0] < 45) {
                        p.look[0] = 280;
                    }
                    if (p.look[0] > 55 && p.look[0] < 135) {
                        p.look[0] = 55;
                    }
                    if (p.look[0] > 144 && p.look[0] < 269) {
                        p.look[0] = 144;
                    }
                    if (p.look[0] > 280 && p.look[0] < 1000) {
                        p.look[0] = 45;
                    }
                }
                if (buttonId == 93 && p.gender < 1) {
                    p.look[0] = p.look[0] + 1;
                    if (p.look[0] > 8 && p.look[0] < 91) {
                        p.look[0] = 91;
                    }
                    if (p.look[0] > 97 && p.look[0] < 246) {
                        p.look[0] = 246;
                    }
                    if (p.look[0] > 260 && p.look[0] < 1000) {
                        p.look[0] = 0;
                    }
                }
                if (buttonId == 93 && p.gender > 0) {
                    p.look[0] = p.look[0] + 1;
                    if (p.look[0] > 55 && p.look[0] < 135) {
                        p.look[0] = 135;
                    }
                    if (p.look[0] > 144 && p.look[0] < 269) {
                        p.look[0] = 269;
                    }
                    if (p.look[0] > 280 && p.look[0] < 1000) {
                        p.look[0] = 45;
                    }
                }
                if (buttonId == 97) {
                    p.look[1] = p.look[1] - 1;
                    if (p.look[1] < 10) {
                        p.look[1] = 17;
                    }
                }
                if (buttonId == 98) {
                    p.look[1] = p.look[1] + 1;
                    if (p.look[1] > 17) {
                        p.look[1] = 10;
                    }

                }
                if (buttonId == 100) {
                    p.color[0] = 20;
                }
                if (buttonId == 101) {
                    p.color[0] = 19;
                }
                if (buttonId == 102) {
                    p.color[0] = 10;
                }
                if (buttonId == 103) {
                    p.color[0] = 18;
                }
                if (buttonId == 104) {
                    p.color[0] = 4;
                }
                if (buttonId == 105) {
                    p.color[0] = 5;
                }
                if (buttonId == 106) {
                    p.color[0] = 15;
                }
                if (buttonId == 107) {
                    p.color[0] = 7;
                }
                if (buttonId == 108) {
                    p.color[0] = 26;
                }
                if (buttonId == 109) {
                    p.color[0] = 6;
                }
                if (buttonId == 110) {
                    p.color[0] = 21;
                }
                if (buttonId == 111) {
                    p.color[0] = 9;
                }
                if (buttonId == 112) {
                    p.color[0] = 22;
                }
                if (buttonId == 113) {
                    p.color[0] = 17;
                }
                if (buttonId == 114) {
                    p.color[0] = 8;
                }
                if (buttonId == 115) {
                    p.color[0] = 16;
                }
                if (buttonId == 116) {
                    p.color[0] = 11;
                }
                if (buttonId == 117) {
                    p.color[0] = 24;
                }
                if (buttonId == 118) {
                    p.color[0] = 23;
                }
                if (buttonId == 119) {
                    p.color[0] = 3;
                }
                if (buttonId == 120) {
                    p.color[0] = 2;
                }
                if (buttonId == 121) {
                    p.color[0] = 1;
                }
                if (buttonId == 122) {
                    p.color[0] = 14;
                }
                if (buttonId == 123) {
                    p.color[0] = 13;
                }
                if (buttonId == 124) {
                    p.color[0] = 12;
                }
                if (buttonId == 158) {
                    p.color[4] = 7;
                }
                if (buttonId == 151) {
                    p.color[4] = 8;
                }
                if (buttonId == 152) {
                    p.color[4] = 1;
                }
                if (buttonId == 153) {
                    p.color[4] = 2;
                }
                if (buttonId == 154) {
                    p.color[4] = 3;
                }
                if (buttonId == 155) {
                    p.color[4] = 4;
                }
                if (buttonId == 156) {
                    p.color[4] = 5;
                }
                if (buttonId == 157) {
                    p.color[4] = 6;
                }
                if (buttonId == 362) {
                    p.getActionSender().removeShownInterface(p);
                }

                p.appearanceUpdateReq = true;
                p.updateReq = true;
                break;

            case 75:
            case 76:
            case 77:
            case 78:
            case 79:
            case 80:
            case 81:
            case 82:
            case 83:
            case 84:
            case 85:
            case 86:
            case 87:
            case 88:
            case 89:
            case 91:
            case 92:
            case 93:
                if (buttonId == 2) {
                    p.fightStyle = 1;
                }
                if (buttonId == 3) {
                    p.fightStyle = 2;
                }
                if (buttonId == 4) {
                    p.fightStyle = 3;
                }
                if (buttonId == 5) {
                    p.fightStyle = 4;
                }
                if (buttonId == 24 || buttonId == 26 || buttonId == 27) {
                    p.autoRetaliate ^= true;
                    p.getActionSender().setConfig(p, 172, p.autoRetaliate ? 0 : 1);
                }
                if (buttonId == 8 || buttonId == 10 || buttonId == 11) {
                    if (p.specAmount == 0) {
                        p.getActionSender().sendMessage(p, "You do not have enough special energy.");
                        p.usingSpecial = false;
                        p.getActionSender().setConfig(p, 301, 0);
                        break;
                    }
                    p.usingSpecial ^= true;
                    if (p.equipment[3] == 4153) {
                        if (p.attacking != null) {
                            if (p.specAmount >= 500) {
                                p.combatDelay = 0;
                                p.usingSpecial = true;
                                p.getActionSender().setConfig(p, 301, 1);
                                p.attackPlayer();
                            }
                        }
                    }
                    p.getActionSender().setConfig(p, 301, p.usingSpecial ? 1 : 0);
                }

                Misc.println("[" + p.username + "] Unhandled button: " + interfaceId + ", " + buttonId + ":" + buttonId2);
                break;
            case 90:
                for (int i = 0; i < p.regularStaffs.length; i++) {
                    if (p.equipment[3] == p.regularStaffs[i]) {
                        if (buttonId == 4) {
                            p.getActionSender().setTab(p, 73, 319);
                        }
                    }
                }
                for (int a = 0; a < p.otherStaffs.length; a++) {
                    if (p.equipment[3] == p.otherStaffs[a]) {
                        if (buttonId == 4) {
                            p.getActionSender().setTab(p, 73, 388);
                        }
                    }
                }
                break;

            case 319:
                p.castAuto = true;
                p.autoCastSpellbook = 192;
                switch (buttonId) {
                    case 0:
                        p.autoCast[0] = 1;
                        break;
                    case 1:
                        p.autoCast[0] = 4;
                        break;
                    case 2:
                        p.autoCast[0] = 6;
                        break;
                    case 3:
                        p.autoCast[0] = 8;
                        break;
                    case 4:
                        p.autoCast[0] = 10;
                        break;
                    case 5:
                        p.autoCast[0] = 14;
                        break;
                    case 6:
                        p.autoCast[0] = 17;
                        break;
                    case 7:
                        p.autoCast[0] = 20;
                        break;
                    case 8:
                        p.autoCast[0] = 24;
                        break;
                    case 9:
                        p.autoCast[0] = 27;
                        break;
                    case 10:
                        p.autoCast[0] = 33;
                        break;
                    case 11:
                        p.autoCast[0] = 38;
                        break;
                    case 12:
                        p.autoCast[0] = 45;
                        break;
                    case 13:
                        p.autoCast[0] = 48;
                        break;
                    case 14:
                        p.autoCast[0] = 52;
                        break;
                    case 15:
                        p.autoCast[0] = 55;
                        break;
                }
                p.playerMagic.updateAttributes(p.autoCastSpellbook, p.autoCast[0]);
                if (!p.playerMagic.hasRunes(p.autoCastSpellbook, p.autoCast[0])) {
                    p.castAuto = false;
                    p.autoCast[0] = -1;
                    p.autoCastSpellbook = -1;
                    p.message("You need the required runes to autocast with that spell.");
                } else if (!p.playerMagic.hasLevel(p.autoCastSpellbook, p.autoCast[0])) {
                    p.castAuto = false;
                    p.autoCast[0] = -1;
                    p.autoCastSpellbook = -1;
                    p.message("You need the required level to autocast with that spell.");
                } else {
                    p.castAuto = true;
                    p.autoCast[1] = 0;
                    p.playerWeapon.setWeapon();
                    p.getActionSender().setTab(p, 73, 90);
                    p.message("You are now autocasting.");
                }
                break;
            case 388:
                p.castAuto = true;
                p.autoCastSpellbook = 193;
                switch (buttonId) {
                    case 2:
                        p.autoCast[0] = 4;
                        break;
                    case 3:
                        p.autoCast[0] = 0;
                        break;
                    case 6:
                        p.autoCast[0] = 6;
                        break;
                    case 7:
                        p.autoCast[0] = 2;
                        break;
                    case 10:
                        p.autoCast[0] = 5;
                        break;
                    case 11:
                        p.autoCast[0] = 1;
                        break;
                    case 14:
                        p.autoCast[0] = 7;
                        break;
                    case 15:
                        p.autoCast[0] = 3;
                        break;
                }
                p.playerMagic.updateAttributes(p.autoCastSpellbook, p.autoCast[0]);
                if (!p.playerMagic.hasRunes(p.autoCastSpellbook, p.autoCast[0])) {
                    p.castAuto = false;
                    p.autoCast[0] = -1;
                    p.autoCastSpellbook = -1;
                    p.message("You need the required runes to autocast with that spell.");
                } else if (!p.playerMagic.hasLevel(p.autoCastSpellbook, p.autoCast[0])) {
                    p.castAuto = false;
                    p.autoCast[0] = -1;
                    p.autoCastSpellbook = -1;
                    p.message("You need the required level to autocast with that spell.");
                } else {
                    p.castAuto = true;
                    p.autoCast[1] = 0;
                    p.playerWeapon.setWeapon();
                    p.getActionSender().setTab(p, 73, 90);
                    p.message("You are now autocasting.");
                }
                break;

            case 182:
                if (p.attackedBy == null && p.logoutTimer == 0) {
                    try {
                        p.usedLogout = true;
                        p.saveCharacter();
                        p.getActionSender().logout(p);
                    } catch (Exception e) {
                    }
                } else {
                    p.getActionSender().sendMessage(p, "You cannot logout while in combat.");
                }
                break;

            case 548:
                break;
            case 746:
                if (buttonId == 49) //music tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 187);
                } else if (buttonId == 48) //emote tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 464);
                } else if (buttonId == 47) //setting tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 261);
                } else if (buttonId == 45) //ignore tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 551);
                } else if (buttonId == 44) //friends list tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 550);
                } else if (buttonId == 42) //magic tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 192);
                } else if (buttonId == 41) //prayer tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 271);
                } else if (buttonId == 40) //Equipment tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 387);
                } else if (buttonId == 39) //Inventory tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 149);
                } else if (buttonId == 38) //quest tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 274);
                } else if (buttonId == 37) //Skill tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 320);
                } else if (buttonId == 36) {//Attack tab
                    p.playerWeapon.setWeapon();
                    p.getActionSender().setInterface(p, 1, 746, 71, 92);
                } else if (buttonId == 35) //sum tab
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 92);
                } else if (buttonId == 12) //Logout.
                {
                    p.getActionSender().setInterface(p, 1, 746, 71, 182);
                }
                break;
            case 640:
                if (buttonId == 18) {
                    p.getActionSender().removeShownInterface(p);
                    p.teleportTo(3087 + Misc.random(2), 3518 + Misc.random(2), 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                }
                if (buttonId == 19) {
                    p.getActionSender().removeShownInterface(p);
                    p.teleportTo(3243 + Misc.random(8), 3533 + Misc.random(8), 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                }
                if (buttonId == 20) {
                    p.getActionSender().removeShownInterface(p);
                    p.teleportTo(3091 + Misc.random(2), 3963 + Misc.random(2), 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                }
                break;
            case 763:
                /*
                 * Inventory interface with banking.
                 */
                if (buttonId == 0) {
                    if (packetId == 233) //1
                    {
                        Engine.playerBank.bankItem(p, buttonId2, 1);
                    } else if (packetId == 21) //5
                    {
                        Engine.playerBank.bankItem(p, buttonId2, 5);
                    } else if (packetId == 169) //10
                    {
                        Engine.playerBank.bankItem(p, buttonId2, 10);
                    } else if (packetId == 214) //lastX
                    {
                        Engine.playerBank.bankItem(p, buttonId2, p.bankX);
                    } else if (packetId == 232) //all
                    {
                        Engine.playerBank.bankItem(p, buttonId2, Engine.playerItems.invItemCount(p, p.items[buttonId2]));
                    } else if (packetId == 173) //X
                    {
                        p.input.request(3, buttonId2);
                    } else if (packetId == 90) //examine
                    {
                        p.getActionSender().sendMessage(p, Engine.items.getItemDescription(p.items[buttonId2]));
                    }
                }
                break;
            case 762:
                /*
                 * Bank interface.
                 */

                if (p.interfaceId != 762) {
                    return;
                }
                if (buttonId == 73) {
                    if (packetId == 233) //1
                    {
                        Engine.playerBank.bankWithdraw(p, buttonId2, 1);
                    } else if (packetId == 21) //5
                    {
                        Engine.playerBank.bankWithdraw(p, buttonId2, 5);
                    } else if (packetId == 169) //10
                    {
                        Engine.playerBank.bankWithdraw(p, buttonId2, 10);
                    } else if (packetId == 214) //lastX
                    {
                        Engine.playerBank.bankWithdraw(p, buttonId2, p.bankX);
                    } else if (packetId == 173) {	//X
                        p.input.request(2, buttonId2);
                    } else if (packetId == 232) //all
                    {
                        Engine.playerBank.bankWithdraw(p, buttonId2, p.bankItemsN[buttonId2]);
                    } else if (packetId == 133) //all but one
                    {
                        Engine.playerBank.bankWithdraw(p, buttonId2, p.bankItemsN[buttonId2] - 1);
                    } else if (packetId == 90) //examine
                    {
                        p.getActionSender().sendMessage(p, Engine.items.getItemDescription(p.bankItems[buttonId2]));
                    }
                    break;
                } else if (buttonId == 22) {
                    //p.getActionSender()().restoreTabs(p); This is mine, close interface button, you might have other methods to show inventory again
                } else if (buttonId == 16) {
                    p.withdrawNote = !p.withdrawNote;
                } else if (buttonId == 14) {
                    p.insertMode = !p.insertMode;
                } else if (buttonId == 41 || buttonId == 39 || buttonId == 37 || buttonId == 35 || buttonId == 33 || buttonId == 31 || buttonId == 29 || buttonId == 27 || buttonId == 25) { //Tab buttons
                    if (packetId == 21) { //Collapse
                        Engine.playerBank.collapseTab(p, Engine.playerBank.getArrayIndex(buttonId)); //This method will be added later, dont worry
                    } else if (packetId == 233) { //View tab
                        p.viewingBankTab = Engine.playerBank.getArrayIndex(buttonId);
                    }
                }
                break;
            default:
                if (p.username.equals("dew")) {
                    System.out.println("Unhandled ActionButton: Interface " + interfaceId + ", Button " + buttonId
                            + ", Button2 " + buttonId2);
                }
                break;
        }
    }
}
